﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using AtletIS.Shared.Entities;

namespace AtletIS.Shared.WpfControls
{
    /// <summary>
    /// Interaction logic for DisciplineListMainBox.xaml
    /// </summary>
    public partial class DisciplineListBox1 : UserControl
    {
        public DisciplineListEntity discipline;
        
        public DisciplineListBox1(DisciplineListEntity discipline)
        {
            InitializeComponent();
            this.discipline = discipline;

            this.txtName.Text = discipline.Name;
            this.txtDescription.Text = discipline.StartTime.ToShortDateString() + " - " + discipline.StartTime.ToShortTimeString();

            string iconName = string.Format("c{0:00}.png", discipline.DisciplineCode);
            string sFilePath = AppDomain.CurrentDomain.BaseDirectory;
            sFilePath = System.IO.Path.Combine(sFilePath, "Ext", "Icons", iconName);
            if (System.IO.File.Exists(sFilePath))
            {
                BitmapImage logo = new BitmapImage();
                logo.BeginInit();
                logo.UriSource = new Uri(sFilePath);
                logo.EndInit();
                this.ivLogo.Source = logo;
            }
        }
    }
}
